#ifndef WINDOWHOLDERUI_H
#define WINDOWHOLDERUI_H

#include <QWidget>
#include <optra/common/guiwindow.h>

#include <QResizeEvent>
#include "point3d.h"

#include <QGraphicsScene>

namespace Ui {
    class WindowHolderUi;
}

class Scene;

class WindowHolderUi : public Optra::GuiWindow {
    Q_OBJECT
public:
    WindowHolderUi(QWidget *parent = 0, Optra::GuiWindow* holder = 0);
    ~WindowHolderUi();

    Optra::GuiWindow* holder()const { return holder_; }

    void addWidgetProxy(QGraphicsProxyWidget* proxy);
    void adjustSize();
public slots:
    void next();
    void previous();
    void view(int i);
    void grid();
    void single(int i = -1);

private slots:
    void selectionChanged();
    void testState();

signals:
    void animation();
    void animation2();
protected:
    void changeEvent(QEvent *e);
    void resizeEvent(QResizeEvent * event);
private:


    void centerWidget(QGraphicsProxyWidget* w);
    QPointF centerPos(QGraphicsProxyWidget* w);

    Ui::WindowHolderUi *ui;

    Optra::GuiWindow* holder_;

    void setupAnimation();

    Scene * scene_;
    QList<QGraphicsProxyWidget*> items_;
    int current_;

    QStateMachine* states;
    QState *rootState;
    QState *tiledState;
    QState *ellipseState;
    
    QState *baseState;

    QState *figure8State;
    QState *randomState;

    QState *centeredState;
};

#endif // WINDOWHOLDERUI_H
